<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>考试成绩展示</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
    <style>
        body {
            background-color: #f2f3f5;
            font-family: "Microsoft YaHei", sans-serif;
        }

        .score-container {
            max-width: 800px;
            margin: 40px auto;
            padding: 20px;
        }

        .score-card {
            background-color: #fff;
            border-radius: 8px;
            box-shadow: 0 2px 12px rgba(0,0,0,0.05);
            overflow: hidden;
            border: 1px solid #e6e6e6;
        }

        .score-header {
            padding: 20px 30px;
            border-bottom: 1px solid #eee;
            font-size: 18px;
            font-weight: bold;
            color: #36aafd;
            background-color: #f8fafc;
        }

        .score-content {
            padding: 40px;
            text-align: center;
        }

        .score-number {
            width: 160px;
            height: 160px;
            margin: 30px auto;
            border-radius: 50%;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            border: 6px solid #fff;
            background: linear-gradient(135deg, #36aafd 0%, #1e88e5 100%);
            color: white;
            opacity: 0;
            transform: rotate(0deg);
            transition: all 1.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
        }

        .score-number.animate {
            opacity: 1;
            border: 6px solid #36aafd;
            transform: rotate(360deg);
            box-shadow: 0 0 30px rgba(54, 170, 253, 0.3);
        }

        .score-value {
            font-size: 48px;
            font-weight: 700;
            line-height: 1.2;
        }

        .score-label {
            font-size: 18px;
            letter-spacing: 2px;
        }

        .time-info {
            margin-top: 40px;
            width: 100%;
        }

        .time-item {
            display: flex;
            justify-content: space-between;
            padding: 16px 24px;
            margin-bottom: 15px;
            border-radius: 6px;
            font-size: 16px;
        }

        .start-time {
            background-color: #fcf8e3;
            color: #8a6d3b;
            border-left: 4px solid #f0ad4e;
        }

        .end-time {
            background-color: #e9f5e9;
            color: #3c763d;
            border-left: 4px solid #5cb85c;
        }

        .time-label {
            font-weight: bold;
        }

        .time-value {
            font-weight: 500;
        }

        .action-buttons {
            margin-top: 40px;
            display: flex;
            justify-content: center;
            gap: 20px;
        }

        .action-btn {
            width: 180px;
            height: 50px;
            border-radius: 30px;
            font-size: 16px;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.3s;
        }

        .action-btn i {
            margin-right: 8px;
        }

        .action-btn:hover {
            transform: translateY(-3px);
            box-shadow: 0 5px 15px rgba(0,0,0,0.1);
        }

        .result-text {
            margin-top: 30px;
            font-size: 20px;
            color: #555;
        }

        .result-pass {
            color: #5cb85c;
            font-weight: bold;
        }

        .result-fail {
            color: #d9534f;
            font-weight: bold;
        }

        .decoration {
            position: absolute;
            width: 120px;
            height: 120px;
            opacity: 0.1;
            z-index: 0;
        }

        .decoration-1 {
            top: 20%;
            left: 10%;
            background: radial-gradient(#36aafd, transparent 70%);
        }

        .decoration-2 {
            bottom: 20%;
            right: 10%;
            background: radial-gradient(#5cb85c, transparent 70%);
        }

        @media (max-width: 768px) {
            .score-container {
                padding: 10px;
                margin: 20px auto;
            }

            .score-content {
                padding: 20px;
            }

            .score-number {
                width: 140px;
                height: 140px;
            }

            .score-value {
                font-size: 40px;
            }

            .action-buttons {
                flex-direction: column;
                align-items: center;
            }
        }
    </style>
</head>
<body>
<div class="layui-container score-container">
    <div class="score-card">
        <div class="score-header">
            <i class="fa fa-bar-chart"></i> 本次考试成绩
        </div>

        <div class="score-content">
            <!-- 装饰元素 -->
            <div class="decoration decoration-1"></div>
            <div class="decoration decoration-2"></div>

            <div class="score-number" id="scoreNumber">
                <span class="score-value" id="scoreValue">0</span>
                <span class="score-label">分数</span>
            </div>

            <div class="result-text">
                考试结果：<span id="resultText" class="result-pass">恭喜您通过考试！</span>
            </div>

            <div class="time-info">
                <div class="time-item start-time">
                    <span class="time-label">开始时间</span>
                    <span class="time-value" id="startTime">2023-11-23 14:30:00</span>
                </div>

                <div class="time-item end-time">
                    <span class="time-label">结束时间</span>
                    <span class="time-value" id="endTime">2023-11-23 16:30:00</span>
                </div>
            </div>

            <div class="action-buttons">
                <button class="layui-btn layui-btn-normal action-btn" id="reviewBtn">
                    <i class="fa fa-file-text"></i> 查看试卷
                </button>
                <button class="layui-btn action-btn" id="returnBtn">
                    <i class="fa fa-home"></i> 返回首页
                </button>
            </div>
        </div>
    </div>
</div>

<script src="../../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    layui.use(['layer'], function(){
        var layer = layui.layer;
        
        // 获取URL参数
        function getQueryParam(name) {
            const urlParams = new URLSearchParams(window.location.search);
            return urlParams.get(name);
        }

        // 获取分数参数
        const score = getQueryParam('score') || 0;
        const startTime = getQueryParam('startTime') || new Date().toLocaleString();
        const endTime = getQueryParam('endTime') || new Date().toLocaleString();

        console.log('获取到的分数:', score); // 调试用

        // 更新页面数据
        document.getElementById('scoreValue').textContent = score;
        document.getElementById('startTime').textContent = startTime;
        document.getElementById('endTime').textContent = endTime;

        // 根据分数设置结果文本
        const resultText = document.getElementById('resultText');
        if (score >= 60) {
            resultText.textContent = '恭喜您通过考试！';
            resultText.className = 'result-pass';
        } else {
            resultText.textContent = '很遗憾，请继续努力！';
            resultText.className = 'result-fail';
        }

        // 分数动画效果
        setTimeout(() => {
            document.getElementById('scoreNumber').classList.add('animate');

            // 分数递增动画
            if (score > 0) {
                let currentScore = 0;
                const increment = Math.ceil(score / 30);
                const timer = setInterval(() => {
                    currentScore += increment;
                    if (currentScore >= score) {
                        currentScore = score;
                        clearInterval(timer);
                    }
                    document.getElementById('scoreValue').textContent = currentScore;
                }, 40);
            }
        }, 500);

        // 按钮事件
        document.getElementById('reviewBtn').addEventListener('click', function() {
            layer.msg('查看试卷功能', {icon: 1, time: 1500});
        });

        document.getElementById('returnBtn').addEventListener('click', function() {
            window.location.href = 'examTable.html';
        });
    });
</script>
</body>
</html>